import http from '../../http/http'
const state = {
    demo:[
        // {number: '1',name: '王小虎',password: '123',sex:'1',tel:'13281111111',idCard:'11111111',money:'0'},
        // {number: '2',name: '王虎',password: '123',sex:'2',tel:'13281111111',idcard:'11111111',money:'0'},
        // {number: '3',name: '王大虎',password: '123', sex:'2',tel:'13281111111',idcard:'11111111',money:'0'},
        // {number: '4',name: '王小虎',password: '123',sex:'2',tel:'13281111111',idcard:'11111111',money:'0'},
        // {number: '5',name: '王小虎',password: '123',sex:'1',tel:'13281111111',idcard:'11111111',money:'0'},
        // {number: '6',name: '王小虎',password: '123',sex:'1',tel:'13281111111',idcard:'11111111',money:'0'},
        // {number: '7',name: '王小虎',password: '123',sex:'1',tel:'13281111111',idcard:'11111111',money:'0'},
        // {number: '8',name: '王小虎',password: '123',sex:'2',tel:'13281111111',idcard:'11111111',money:'0'},
        // {number: '9',name: '王小虎',password: '123',sex:'1',tel:'13281111111',idcard:'11111111',money:'0'},
        // {number: '10',name: '王小虎',password: '123',sex:'2',tel:'13281111111',idcard:'11111111',money:'0'},
        // {number: '11',name: '王小虎',password: '123',sex:'1',tel:'13281111111',idcard:'11111111',money:'0'},
        // {number: '12',name: '王小虎',password: '123',sex:'1',tel:'13281111111',idcard:'11111111',money:'0'},
        // {number: '13',name: '王小虎',password: '123',sex:'1',tel:'13281111111',idcard:'11111111',money:'0'},
        // {number: '14',name: '王小虎',password: '123',sex:'1',tel:'13281111111',idcard:'11111111',money:'0'},
    ],
    userSearch:[],
    showUser:[],
    payInfo:{
        // id:0,
        // price:999,
        // time:2020-04-03,
        // item:[
        //     {name:'xxx',num:1,price:999}
        // ]
    },

    payFlag:false,
}
const actions = {

    addUser({ commit },obj){
        // commit('dealAddUser',obj)
        // let zengJiaobj = {
        //     name: obj.name,
        //     password: obj.password,
        //     idCard:obj.idCard,
        //     tel:obj.tel,
        //     sex:obj.sex,
        // }

        return http({
            url:"/website/Employeecontroller/regesterUser",
            method:"post",
            data:{
                name: obj.name,
                password: obj.password,
                idCard:obj.idCard,
                tel:obj.tel,
                sex:obj.sex,
            }
        })
        .then(res => {
            console.log(res.data);
        })

        // .then(res => {
        //     console.log(zengJiaobj)
        //     http({
        //         url:'/website/Employeecontroller/selectUser',
        //         method:"post",
        //         data:{}
        //     }).then(res => {
        //         commit("dealAddUser",res.data)
        //         console.log(res.data)
        //     }).catch(err => {
        //         console.log(err)
        //     })
        // })
    },

    allHuiyuan({commit}){
        http({
            url:'/website/Employeecontroller/selectUser',
            method:'post',
            data:{}
        }).then(res => {
            if(res.status == 200){
                commit('getAllhy',res.data)
                for(let i=0;i<=res.data.length;i++){
                    if(res.data[i].sex === 1){
                        res.data[i].sex = "男"
                    }else{
                        res.data[i].sex = "女"
                    }
                }
                
            }
        }).catch(err => {
            // console.log(err)
        })
    },


    // userSearch({commit},obj){
    //     let { searchType, input } = obj
    //     state.demo = (state.demo.filter(item => item[searchType] == input))
        
    // },
    // userSearch2({commit},obj){
    //     let { searchType, input } = obj
    //     state.demo = (state.demo.filter(item => item[searchType] == input))
    // },
    vipPayInfo({commit},obj){
        console.log(obj);
        commit('dealvipPayInfo',obj)
    },
    
}
const mutations = {
    dealAddUser(context,obj){
        console.log(obj)
        state.demo = data
        state.demo.push(...obj)
        // console.log(obj)
        // console.log(state.demo)
    },

    getAllhy(state,data){
        state.demo = data
    },
    
    dealvipPayInfo(context,obj){
        state.payInfo = obj
    }
}
const getters = {}
export default {
    state,
    actions,
    mutations,
    getters
}